package b2.scene.fight.skills
{
	import b2.config.Config;
	import b2.config.EnemyConfig;
	import b2.scene.fight.FightScene;
	import b2.scene.fight.TankSprite;

	public class IceStorm extends BasicSkill
	{
		public function IceStorm(tankId:int, tankSide:int ,level:int, skillArgs:Object)
		{
			super(tankId, tankSide ,level, skillArgs);
		}
		
		public override function checkSkillTriggerPremise(x:int, y:int, direction:int):Boolean
		{
			var tank:TankSprite = getPlayState().tanks[tankId];
			var enemyConfig:EnemyConfig = Config.enemyConfigs[tank.enemyIndex];
			if (coolDown < 0)
			{
				var message:String = "<font color='#0000FF'>" + enemyConfig.name + "</font>发动了<font color='#FF0000'>" + skillArgs.name + "</font>";
				FightScene.getInstance().showBottomMessage(message);
				tank.showMessageFlag = false;
				return true;
			}
			else if (!tank.showMessageFlag && coolDown == 6)
			{
				message = "<font color='#0000FF'>" + enemyConfig.name + "</font><font color='#00AA00'> 5 </font>秒后发动<font color='#FF0000'>" 
							+ skillArgs.name + "</font>"
				FightScene.getInstance().showTopMessage(message);
				tank.showMessageFlag = true;
				return false;
			}
			return false;
		}
		
		public override function discharge(x:int, y:int, direction:int):void
		{
			var tank:TankSprite = getPlayState().tanks[tankId];
			var effectRange:int = level < skillArgs.effectRange.length ? skillArgs.effectRange[level] : skillArgs.effectRange[0];
			var effectDuration:int = level < skillArgs.effectDuration.length ? skillArgs.effectDuration[level] : skillArgs.effectDuration[0];
			var effectValue:int = level < skillArgs.effectValue.length ? skillArgs.effectValue[level] : skillArgs.effectValue[0];
			var bulletApPlus:int = level < skillArgs.bulletApPlus.length ? skillArgs.bulletApPlus[level] : skillArgs.bulletApPlus[0] * level;
			tank.startFinalWeapon(skillArgs.movieIndex, effectRange, bulletApPlus, skillArgs.effectIndex, effectDuration, effectValue);
			super.discharge(x, y, direction);
		}

		
	}
}